<template>
  <div class="tab1_wrap" v-loading="loading">
    <el-form ref="form" :rules="rules" :model="form" label-width="80px">
      <el-form-item label="名称" prop="tableName">
        <el-input v-model="form.tableName"></el-input>
      </el-form-item>
      <el-form-item label="编码" prop="code">
        <el-input v-model="form.code"></el-input>
      </el-form-item>
      <el-form-item label="描述" prop="textarea">
        <el-input v-model="form.textarea"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">修改</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    propsData: {
      type: Object,
      default: () => {},
    },
  },
  watch: {
    propsData: {
      deep: true,
      handler(val) {
        if (val.tab12) {
          this.form = JSON.parse(JSON.stringify(val.tab12));
        }
      },
    },
  },
  data() {
    return {
      form: {
        tableName: "",
        code: "",
        textarea: "",
      },
      rules: {
        tableName: [{ required: true, message: "请输入名称", trigger: "blur" }],
        code: [{ required: true, message: "请输入编码", trigger: "blur" }],
        textarea: [{ required: true, message: "请输入描述", trigger: "blur" }],
      },
      loading: false,
    };
  },
  beforeDestroy() {},
  created() {},
  mounted() {},
  methods: {
    submitForm() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.loading = true;
          setTimeout(() => {
            let paramsObj = {
              type: "tab1",
              obj: this.form,
            };
            this.$emit("getG6ApiFn", paramsObj);
            this.loading = false;
          }, 500);
        } else {
          return false;
        }
      });
    },
  },
};
</script>

<style lang="less" scoped></style>
